What is clean-stack?
The clean-stack npm package is designed to clean up error stack traces. It removes the noise from stack traces, making them easier to read and understand. This is particularly useful in development and production environments where error logs can become cluttered with irrelevant paths and lines. By simplifying stack traces, developers can more quickly identify the source of errors.
What are clean-stack's main functionalities?
Cleaning stack traces
This feature allows you to clean up the stack trace of an error. The `cleanStack` function takes an error stack as input and returns a cleaner, more readable version of it. This is particularly useful for logging and error handling in applications.
const cleanStack = require('clean-stack');
const error = new Error('An error occurred!');
console.log(cleanStack(error.stack));
Other packages similar to clean-stack
stack-trace
The 'stack-trace' package provides utilities for working with stack traces. It allows you to parse and inspect stack traces. Compared to 'clean-stack', 'stack-trace' offers more detailed manipulation and inspection capabilities but does not focus specifically on cleaning or simplifying the stack traces.
error-stack-parser
This package is used to parse JavaScript Error stack strings and extract stack frames from them. While 'error-stack-parser' focuses on parsing and extracting information from stack traces, 'clean-stack' is more about cleaning and simplifying them for better readability.
clean-stack
Clean up error stack traces
Removes the mostly unhelpful internal Node.js entries.
Also works in Electron.
Install
$ npm install --save clean-stack
Usage
const cleanStack = require('clean-stack');
const error = new Error('Missing unicorn');
console.log(error.stack);
console.log(cleanStack(error.stack));
API
cleanStack(stack, [options])
stack
Type: string
The stack
property of an Error
.
options
Type: Object
pretty
Type: boolean
Default: false
Prettify the file paths in the stack:
/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15
→ ~/dev/clean-stack/unicorn.js:2:15
Related
License
MIT © Sindre Sorhus